package com.hksj.sglm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hksj.common.core.model.Rest;
import com.hksj.sglm.query.OxygenConcentrationQuery;
import com.hksj.sglm.query.OxygenConcentrationTrendQuery;
import com.hksj.sglm.service.OxygenConcentrationService;
import com.hksj.sglm.vo.ConcentrationTrendVO;
import com.hksj.sglm.vo.OxygenConcentrationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "特气泄漏-设备列表")
@RestController
@RequestMapping("/api/oxygenconcentration")
public class OxygenConcentrationController {
    @Autowired
    private OxygenConcentrationService oxygenConcentrationService;

    @ApiOperation(value = "气体泄漏监测设备列表", response = OxygenConcentrationVO.class)
    @PostMapping("/queryDeviceList")
    public Rest<Page<OxygenConcentrationVO>> queryDeviceList(@RequestBody OxygenConcentrationQuery query) {
        Page<OxygenConcentrationVO> page = oxygenConcentrationService.queryDeviceList(query);
        return Rest.ok(page);
    }

    @ApiOperation("根据id查询氧气浓度曲线趋势图")
    @PostMapping("/selectConcentrationTrendById")
    public Rest<List<ConcentrationTrendVO>> selectConcentrationTrendById(@RequestBody OxygenConcentrationTrendQuery query) {
        List<ConcentrationTrendVO> list = oxygenConcentrationService.selectConcentrationTrendById(query);
        return Rest.ok(list);
    }

    @ApiOperation("根据id分页查询氧气浓度")
    @PostMapping("/queryConcentrationTrendById")
    public Rest<Page<ConcentrationTrendVO>> queryConcentrationTrendById(@RequestBody OxygenConcentrationTrendQuery query) {
        Page<ConcentrationTrendVO> list = oxygenConcentrationService.queryConcentrationTrendById(query);
        return Rest.ok(list);
    }

    @ApiOperation("导出氧气浓度历史数据")
    @PostMapping("/exportConcentrationTrend")
    public void exportConcentrationTrend(@RequestBody OxygenConcentrationTrendQuery query, HttpServletResponse response) {
        oxygenConcentrationService.exportConcentrationTrend(query, response);
    }
}
